

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .main {
      width: 660px;
      height: 660px;
      background-image: url('./images/panze.png');
      margin: 100px auto;
      position: relative;
    }
    .zhizhen {
      width: 338px;
      height: 338px;
      background-image: url('./images/zhizhen.png');
      background-repeat: no-repeat;
      background-position: center top;
      position: absolute;
      top: 129px;
      left: 152px;
      transition: transform 500ms linear;
    }
    .begin {
      width: 138px;
      height: 138px;
      position: absolute;
      top: 227px;
      left: 252px;
      border-radius: 50%;
      /* background-color: rgba(255,0,0,.5); */
      
    }
  </style>
</head>
<body>
  <div class="main">
    <div class="zhizhen"></div>
    <div class="begin"></div>
  </div>
</body>
<script>
/*
  抽奖按钮只能点一次
    点击了一次之后，就不能再点了

    思路：
      在点击之后，把点击事件解绑
  
  先实现抽奖
    思路：点击之后，让指针旋转0-360度之间的随机数 transform: rotate(角度)

  步骤：
    1 获取元素
    2 注册点击事件
    3 随机一个角度，修改指针的transform属性
*/
var begin=document.querySelector('.begin');
var zhizhen=document.querySelector('.zhizhen');
begin.addEventListener('click',function(){
  var r=Math.random()*360;
  zhizhen.style.transform='rotate('+r+'deg)';
})



</script>
</html>
